<template>
  <div>
    <div id="editorElem" style="text-align:left" >
    </div>
    <span class="dialog-footer">
      <br>
      <el-button type="primary" @click="testa">取消</el-button>
      <el-button type="primary" @click="testb">保存修改</el-button>
    </span>
  </div>
</template>

<script>
  import E from 'wangeditor'
  export default {
    props: ['contents'],
    data() {
      return {
        editorContent: ''
      }
    },
    methods: {
      testa() {
        this.$emit('funa')
      },
      testb() {
        this.contents.content = this.editorContent
        this.$emit('funb', this.contents)
      }
    },
    created: function() {
      const x = this
      this.$nextTick(function() {
        x.editor.txt.html(this.contents.content)
      })
    },
    mounted() {
      var editor = new E('#editorElem')
      this.editor = editor
      editor.customConfig.onchange = (html) => {
        this.editorContent = html
      }
      editor.create()
    }
  }
</script>

<style scoped>

</style>
